package com.qd.common.sys.domain.entity.role;

import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * @author sjk
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode
public class RoleMenuRelationsDTO {

    /**
     * 角色ID
     */
    @NotBlank(message = "角色ID不能为空",groups = DefaultGroup.class)
    @Size(max = 50, message = "角色ID长度不能超过{max}位",groups = DefaultGroup.class)
    private String roleId;

    /**
     * 角色对应的菜单信息
     */
    @Valid
    @NotEmpty(message = "菜单信息不能为空",groups = {UpdateGroup.class, DeleteGroup.class})
    private List<String> menuList;

    public void freeData(){
        this.roleId = null;
        if(null != menuList){
            menuList.clear();
            menuList = null;
        }
    }
}
